package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.entity.NursingProject;
import com.zzyl.mapper.CustomerOrdersProjectMapper;
import com.zzyl.service.CustomerOrdersProject;
import com.zzyl.vo.NursingProjectVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class CustomerOrdersProjectImpl implements CustomerOrdersProject {

    private final CustomerOrdersProjectMapper customerOrdersProjectMapper;

    @Override
    public PageResponse<NursingProjectVo> pageList(String name, Integer pageNum, Integer pageSize, Integer status) {
        PageHelper.startPage(pageNum,pageSize);
        List<NursingProjectVo> list = customerOrdersProjectMapper.pageList(name,status);
        Page<NursingProjectVo> page = (Page<NursingProjectVo>) list;
        return PageResponse.of(page,NursingProjectVo.class);
    }

    @Override
    public NursingProjectVo getById(Integer id) {
        NursingProject nursingProject = customerOrdersProjectMapper.getById(id);
        NursingProjectVo nursingProjectVo = new NursingProjectVo();
        BeanUtil.copyProperties(nursingProject,nursingProjectVo);
        return nursingProjectVo;
    }
}
